home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Miscellaneous / Headlines Code / Headlines Project ƒ / HeadlinesMain.h < prev    next >
Text File  |  1992-11-07  |  3KB  |  126 lines

  1. /*
  2.  * Headlines.h
  3.  *
  4.  */
  5.  
  6.  
  7.  
  8. /******************************/
  9.  
  10. #pragma once
  11.  
  12. /******************************/
  13.  
  14. #include <JADG.h>
  15.  
  16. #include <JRandom.h>
  17.  
  18. /******************************/
  19.  
  20. enum {
  21.     kSpeedControl = 0,
  22.     kColorControl
  23. } ;
  24.  
  25. #define kMaxNFonts (4)
  26.  
  27. enum {
  28.     unknownErr = 1024,
  29.     expectedClassDefnErr,
  30.     expectedClassInstanceErr,
  31.     tooManyClassesErr,
  32.     badClassHeaderErr,
  33.     badLineWeightErr,
  34.     noHeadlinesErr,
  35.     noMainClassErr,
  36.     storageAlreadyInitedErr,
  37.     noFontInfoErr,
  38.     badFontInfoErr,
  39.     retryDisplayErr
  40. } ;
  41.  
  42. #define kMaxNClasses (300L)
  43. #define kMaxNCharsPerLine (256)
  44. #define kMaxNBytesInDef (2000L)
  45. #define kMaxNTags (50)
  46.  
  47. /******************************/
  48.  
  49. typedef struct def_struct {
  50.     short                        cumul;
  51.     char                        *str;
  52.     struct def_struct        *next;
  53. } defn;
  54.  
  55.     /*
  56.      * Within a definition, names of subdefinitions are bracketed in BSLASH
  57.      * and SLASH chars.  Definitions are null-terminated.  The SLASH char is
  58.      * always followed by a variant tag (the default is " ").
  59.      */
  60. #define BSLASH ('\\')
  61. #define SLASH ('/')
  62. #define VBAR ('|')
  63.  
  64.  
  65.     /* These are here so that I don't confuse the poor Balancer. */
  66. #define LBRACE ('{')
  67. #define RBRACE ('}')
  68.  
  69.     /*
  70.      * Note that THINK C's object extensions must be turned off to use the
  71.      * name "class," which is otherwise a keyword.
  72.      */
  73. typedef struct {
  74.     short            weight;
  75.     defn            *list;
  76.     char            *name;
  77.     char            *tags;
  78. } class;
  79.  
  80. /******************************/
  81.  
  82.     /* A global for the storage, so I don't have to keep passing it around. */
  83. extern Handle *gStorage;
  84.  
  85.     /* The input resource (corresponds to "InFile"), its mark, and its length. */
  86. extern char **gInRsrcHndl;
  87. extern long gInRsrcMark;
  88. extern long gInRsrcLength;
  89.  
  90.     /* Is a headline currently being displayed? */
  91. extern Boolean gHeadlineIsUp;
  92.  
  93.     /* The time at which the last headline was displayed or removed. */
  94. extern unsigned long gLastActionTicks;
  95.  
  96.     /* The current line being read in. */
  97. extern char gInLine[kMaxNCharsPerLine];
  98.  
  99.     /* How many classes there are. */
  100. extern short gNClasses;
  101.  
  102.     /* A pointer to the array of class records. */
  103. extern class *gClass;
  104.  
  105.     /* The default tags (shared). */
  106. extern char gNullTags[];
  107.  
  108.     /* The ID of class MAIN. */
  109. extern short gCompMain;
  110.  
  111.     /* The data for JRandom. */
  112. extern jrStruct gJR;
  113.  
  114.     /* The headline that will be, is, or was being displayed. */
  115. extern Str255 gHeadline;
  116. #define jPutChar(c) ( gHeadline[ ++gHeadline[0] ] = (c) )
  117.  
  118.     /* The bastardized "class" that contains font and style information. */
  119. extern class gFontClass;
  120.  
  121. /******************************/
  122.  
  123. extern Boolean gHasFreedHeadlinesAllocations;
  124. extern void freeHeadlinesAllocations(void);
  125. extern void freeHeadlinesAllocationsIfErr(OSErr theOSErr);
  126.